package com.briup.app01.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.app01.bean.Activity;
import com.briup.app01.service.ActivityService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/activity")
@Api(description = "客户活动管理")
public class ActivityController {
	
	@Autowired
	private ActivityService atvService;
	
	@PostMapping("/save")
	@ApiOperation("保存活动信息")
	public String save(Activity activity) {
		atvService.save(activity);
		return "保存成功";
		}
	
	@GetMapping("/deleteById")
	//对方法的描述
	@ApiOperation("根据id删除活动")
	//对参数的描述
	@ApiImplicitParam(name = "id",value="活动id",dataType="int",paramType = "query",required = true)
	public String deleteById(int id) {
		atvService.deleteById(id);
		return "删除成功";
		}
	
	@PostMapping("/update")
	@ApiOperation("更新活动信息")
	public String update(Activity activity) {
		atvService.update(activity);
		return "更新成功";
		}
	
	@GetMapping("/selectById")
	@ApiOperation("根据id查询活动")
	@ApiImplicitParam(name = "id",value="活动id",dataType="int",paramType = "query",required = true)
	public Activity selectById(int id) {
		Activity activity = atvService.selectById(id);
		return activity;
		}
	
	@GetMapping("/selectAll")
	@ApiOperation("查询全部")
	public List<Activity> selectAll() {
		return atvService.selectALL();
		}

	
}
